package inner;


class OutClass2{
    public int data1 = 1;
    int data2 = 2;
    public static int data3 = 3;

    public void test(){
        System.out.println("out::test()");
    }

    //静态内部类
    static class InnerClass2{
        public int data4 = 4;
        int data5 = 5;
        public static int data6 = 6;

        public void fun(){
            System.out.println("out::fun()");
            OutClass2 outClass2 = new OutClass2();
            System.out.println(outClass2.data1);


            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }


}




public class Test2 {
    public static void main1(String[] args) {
        OutClass2.InnerClass2 innerClass2 = new OutClass2.InnerClass2();
        innerClass2.fun();
    }
public void fun2(){
        //局部内部类
        class Inner{
            public void test(){
                System.out.println("hello");
            }
        }

        Inner inner = new Inner();
        inner.test();
}

    public static void main(String[] args) {
        //Test2.Inner inner = null;  error 局部内部类只能在该方法体内部实例化和使用
        OutClass2 out = new OutClass2();
        new OutClass2();//匿名对象
        new OutClass2.InnerClass2();//匿名对象
        System.out.println(new OutClass2().data1);//匿名对象

        new OutClass2(){

        };
    }

}
